#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/7/16 10:28
# @File    : side_html.py
# @Description : -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

import sys
from PySide6.QtCore import QUrl
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtWebEngineWidgets import QWebEngineView


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.web_view = QWebEngineView()
        self.setCentralWidget(self.web_view)
        self.show()
        self.load_html()

    def load_html(self):
        # 你可以将这里的 HTML 替换为你的内容
        html_content = """
        <!DOCTYPE html>
        <html>
            <head><title>PySide6 与 HTML 的结合</title></head>
            <body>
                <h1>Hello, PySide6!</h1>
                <p>这是通过 PySide6 显示的 HTML 内容。</p>
                <table id="userTable" border="1">
                    <thead>
                        <tr>
                          <th>头像</th>
                          <th>选择</th>
                          <th>姓名</th>
                          <th>邮箱</th>
                          <!-- 可以添加更多字段 -->
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                          <td><img src="pyflow.png" alt="User 1 Avatar"></td>
                          <td><input type="checkbox"></td>
                          <td>张三</td>
                          <td>zhangsan@example.com</td>
                          <!-- 添加对应字段的值 -->
                        </tr>
                        <!-- 复制上面的<tr>来添加更多用户 -->
                    </tbody>
                </table>
            </body>
        </html>
        """
        self.web_view.setHtml(html_content)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    mainWindow = MainWindow()
    sys.exit(app.exec())